import java.util.Scanner;
public class Calculator {
        float a;
        float b;
        public Calculator(){
            System.out.println("欢迎使用计算器！");
        }
        public void add(float a,float b){
            System.out.println("两者之和为："+(a+b));
        }
        public void sub(float a,float b){
            System.out.println("两者之差为："+(a-b));
        }
        public void mul(float a,float b){
            System.out.println("两者之积为："+(a*b));
        }
        public void div(float a,float b){
            if(b!=0)
                System.out.println("两者之商为："+(a/b));
            else
                System.out.println("分母不能为零，请重新计算！");
        }
        public void func(){
            Scanner scan=new Scanner(System.in);
            System.out.println("请输入两个数：");
            a=scan.nextFloat();
            b=scan.nextFloat();
            add(a,b);
            sub(a,b);
            mul(a,b);
            div(a,b);
        }

}
